package com.codeforces.contest.c292;
import java.util.Scanner;


public class _292A {

	static Scanner scanner = new Scanner(System.in);
	static int n;
	static int c, t;
	static int last, longest, qsize;

	public static void main(String[] args) {
		n = scanner.nextInt();
		longest = 0;
		qsize = 0;
		last = 0;
		for (int i=1;i<=n;++i) {
			t = scanner.nextInt();
			c = scanner.nextInt();
			qsize -= Math.min((t - last), qsize);
			qsize += c;
			last = t;
			if (qsize > longest) {
				longest = qsize;
			}
		}
		last += qsize;
		System.out.println(last + " " + longest);
	}

}
